home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 2000 January
/
Macworld (2000-01).dmg
/
Shareware World
/
Icon Utilities
/
IconMacher 1.5.4
/
User Contributions
/
Notarianni Carlo
/
Clean.txt
< prev
Wrap
Text File
|
1999-10-17
|
4KB
|
136 lines
on run
activate
beep
display dialog "Clean By Drag
(c) 1999 By Notarianni Carlo
e-mail: cnotarianni@mix.it
This script is written to clean folder with custom icon generated by
“Icon Macher”© Purple E Software
Just you drag the folder contains custom icon on top of this droplet… and enjoy!" buttons {"OK"} default button 1 with icon stop
end run
on open (fileList)
repeat with theNames in fileList
CheckFiles(theNames as text)
end repeat
end open
to CheckFiles(thisName)
copy thisName as text to thisName
(*
check for files or folders
*)
if folder of (info for file thisName) is true then
set theFolderName to thisName
if the last character of theFolderName is not ¬
":" then set theFolderName to theFolderName & ":"
my clean(theFolderName)
else
-- Ignore file
end if
end CheckFiles
on clean(x)
tell application "Finder"
activate
set i to 32 --incrementer
set s to 10 --left edge of first icon
set t to 30 --top edge of first icon
open folder x
set Nx to 10
set Ny to 10
set ItemNumber to count of item of folder x
set MaxIcon to (count of (every item of folder x whose creator type is "ToyS"))
if MaxIcon < 1 then
beep
display dialog "The folder: " & name of folder x & return & "NOT contains \"IconMacher\" custom icon…" buttons {"OK"} default button 1 with icon stop
return
end if
set MaxText to " Max: " & MaxIcon
-- Ask for Number of icon in Horizontal
set WindowSide to size of container window of folder x
set HWindowSide to first item of WindowSide
set SuggIconNumber to round ((HWindowSide - 70) / 32)
if MaxIcon mod SuggIconNumber = 0 then
set MaxText to MaxText & return & "With current window size I suggest: " & SuggIconNumber
end if
copy false to validX
repeat until validX
copy true to validX
copy 0 to Nx
set UserAnswer to display dialog "Number of icon in Horizontal…" & MaxText default answer "" buttons {"Cancel", "OK"} default button 2 with icon ask
copy result to thisResult
copy text returned of thisResult to UserAnswer
copy button returned of thisResult to UserButtonPressed
if UserButtonPressed is "Cancel" then return
try
copy (UserAnswer as integer) to UserAnswer
on error
copy 0 to UserAnswer
copy false to validX
end try
if UserAnswer ≥ 1 and UserAnswer ≤ MaxIcon then
copy UserAnswer to Nx
else
copy false to validX
end if
-- UserAnwer must divisible by Number of icon…
if Nx > 0 and MaxIcon mod Nx ≠ 0 then copy false to validX
if not validX then
display dialog "Incorrect Number…" default button {"OK"} with icon stop
end if
end repeat
--- Simply Nx*Ny = MaxIcon…
set Ny to MaxIcon div Nx
clean up folder x by name
set IconCounter to 0
set theFolderName to (folder x) as text
repeat with Vert from 0 to (Ny - 1)
repeat with Horiz from 0 to (Nx - 1)
copy IconCounter + 1 to IconCounter
set theIconName to my HiddenBinary(IconCounter)
set ThisIcon to theFolderName & theIconName
set position of file ThisIcon to {s + i * Horiz, t + i * Vert}
end repeat
end repeat
--- Now clean files and folder…
make new folder at (startup disk)
set TempFolder to (result) as text
move (every item of folder x whose creator type is not "ToyS") to folder TempFolder
select {}
close folder theFolderName
open folder theFolderName
set zoomed of container window of folder theFolderName to true
move (every item of folder TempFolder) to folder theFolderName
delete folder TempFolder
empty trash
open folder theFolderName
set zoomed of container window of folder theFolderName to true
end tell
end clean
on HiddenBinary(N)
set HiddenDigit to " " -- Tab & Space
copy (round (N)) to Num
set HiddenNumber to ""
repeat
copy Num mod 2 to s
copy Num div 2 to Num
copy (character (s + 1) of HiddenDigit) & HiddenNumber to HiddenNumber
if Num = 0 then exit repeat
end repeat
--Copy 15 tab before hidden binary number
copy " " & HiddenNumber to HiddenNumber
copy (count of character of HiddenNumber) to L
return (characters (L - 14) thru L of HiddenNumber) as text
end HiddenBinary